/**
 * 
 */

package com.shy.portal.entity;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.google.gson.annotations.Expose;
import com.shy.base.entity.BaseEntity;

/**
 * <p>
 * Title: permission
 * </p>
 * <p>
 * Description:权限實体类
 * </p>
 * <p>
 * Company:
 * </p>
 * 
 * @author H2013788
 */
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
@Entity
@Table(name = "portal_permission")
public class Permission extends BaseEntity{
    private static final long serialVersionUID = 1L;

    /**
     * 菜单ID 外鍵關係
     */
    @Expose
    @ManyToOne
    @JoinColumn(name = "menu_id")
    private Menu menu;

    /**
     * 权限名
     */
    @Expose
    @Column(name = "permission_name")
    private String permissionName;

    /**
     * 权限代码
     */
    @Expose
    @Column(name = "permission_code")
    private String permissionCode;

    /**
     * 权限URL
     */
    @Expose
    @Column(name = "permission_url")
    private String permissionUrl;

    /**
     * 描述
     */
    @Expose
    @Column(name = "description")
    private String description;

    /**
     * 级別
     */
    @Expose
    @Column(name = "permission_level")
    private Integer level;

    /**
     * sort
     */
    @Expose
    @Column(name = "sort")
    private Integer sort;
    
    @OneToMany(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY, orphanRemoval = true)
    @JoinColumn(name = "permission_id", referencedColumnName="id")
    private Set<RolePermission> rolePermissions;


    /**
     * @return the menu
     */
    public Menu getMenu() {
        return menu;
    }

    /**
     * @param menu
     *            the menu to set
     */
    public void setMenu(Menu menu) {
        this.menu = menu;
    }

    /**
     * @return the permissionName
     */
    public String getPermissionName() {
        return permissionName;
    }

    /**
     * @param permissionName
     *            the permissionName to set
     */
    public void setPermissionName(String permissionName) {
        this.permissionName = permissionName;
    }

    /**
     * @return the permissionCode
     */
    public String getPermissionCode() {
        return permissionCode;
    }

    /**
     * @param permissionCode
     *            the permissionCode to set
     */
    public void setPermissionCode(String permissionCode) {
        this.permissionCode = permissionCode;
    }

    /**
     * @return the permissionUrl
     */
    public String getPermissionUrl() {
        return permissionUrl;
    }

    /**
     * @param permissionUrl
     *            the permissionUrl to set
     */
    public void setPermissionUrl(String permissionUrl) {
        this.permissionUrl = permissionUrl;
    }


    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description
     *            the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the level
     */
    public Integer getLevel() {
        return level;
    }

    /**
     * @param level
     *            the level to set
     */
    public void setLevel(Integer level) {
        this.level = level;
    }

    /**
     * @return the sort
     */
    public Integer getSort() {
        return sort;
    }

    /**
     * @param sort
     *            the sort to set
     */
    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public Set<RolePermission> getRolePermissions() {
        return rolePermissions;
    }

    public void setRolePermissions(Set<RolePermission> rolePermissions) {
        this.rolePermissions = rolePermissions;
    }

    
    
}
